let fs = require('fs');

let components = [];
const files = fs.readdirSync('./images/');
files.forEach(function (item) {
    if (item.indexOf('DS_Store') < 0) {
        components.push(item);
    }
});

console.log(components);

fs.writeFileSync('./ImageConstants.js', 'const ImageConstants = {\n');
let string = '';
for (let i = 0; i < components.length; i++) {
    let item = components[i];
    item = item.replace('@3x', '');
    item = item.replace('@2x', '');
    string = string + `${item.replace(/.(png|jpg|gif)/, '').toUpperCase()} : require('./images/${item}')${i === components.length - 1 ? '};\nexport default ImageConstants;' : ',\n'}`;
}
fs.writeFileSync('./ImageConstants.js', string, {
    encoding: 'utf8',
    flag: 'a'
});
